#!/usr/bin/python3.8.9
# -*- coding: utf-8 -*-

# @Author  : Tina Yu
# @Time    : 2021-7-24 22:15
import sys

import pygame

from review.basic.lesson_12.bird import Bird


class Sky:
    """创建一个背景为蓝色的Pygame窗口"""

    def __init__(self):
        """初始化一个窗口"""
        pygame.init()
        self.screen = pygame.display.set_mode((1200, 800))
        pygame.display.set_caption('Blue sky')
        self.bird = Bird(self)

    def run_sky(self):
        """开始运行程序"""
        while True:
            self._check_events()
            self._update_screen()

    def _check_events(self):
        """监控键盘和鼠标事件"""
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()

    def _update_screen(self):
        """更新屏幕上的图像，并切换到新的屏幕"""
        self.screen.fill((43, 81, 126))
        self.bird.blitme()

        # 设置窗口可见
        pygame.display.flip()


if __name__ == '__main__':
    sky = Sky()
    sky.run_sky()
